<template>
<div class="show-size">
  <el-breadcrumb separator-class="el-icon-arrow-right" style="font-size: 16px;">
    <el-breadcrumb-item :to="{ path: '/page/book/BookHotel' }">
      <i class="el-icon-s-promotion"></i> 订酒店首页
    </el-breadcrumb-item>
    <el-breadcrumb-item>酒店搜索</el-breadcrumb-item>
  </el-breadcrumb>
  <el-empty v-if="commentState" :image-size="200"></el-empty>
  <div style="margin: 25px 0px" :key="item.id" v-for="item in hotelArr">
    <el-row  style="height: 200px" :gutter="20">
      <el-col :span="8">
        <div  style="width: 100%;height: 200px;cursor: pointer">
          <el-image
              @click="searchHotelInfo(item.id)"
              style="width: 100%; height: 100%"
              :src="serveUrl+item.url"
              fit="fill"></el-image>
        </div>
      </el-col>
      <el-col :span="16">
        <el-descriptions :column="2" :span="3" :title="item.name">
          <el-descriptions-item  label="地址">{{item.location}}</el-descriptions-item>
          <el-descriptions-item label="类型">
            <el-tag size="small">{{item.type}}</el-tag>
          </el-descriptions-item>
          <el-descriptions-item label="评分">
            <el-rate
                v-model="item.avgScore"
                disabled
                show-score
                text-color="#ff9900"
                score-template="{value}">
            </el-rate>
          </el-descriptions-item>
        </el-descriptions>
      </el-col>
    </el-row>
    <el-divider></el-divider>
  </div>
</div>
</template>

<script>
export default {
  data(){
    return{
      hotelArr:[],
      serveUrl:'http://localhost:9580',
      commentState:true

    }
  },
  methods:{
    searchHotelInfo(id){
      this.$router.push('/page/book/BookHotel-HotelInfo');
      console.log(id);
      localStorage.setItem('hotelId',id);
    },
    loadByContent(content){
      let url = 'http://localhost:9580/hotels/user/getHotelListByContent?content='+content;

      /* let formData=this.qs.stringify(this.activeName1.name);*/
      this.axios
          .create({'headers': {'Authorization': localStorage.getItem('jwt')}})
          .get(url).then((response) => {
        let responseBody = response.data;
        this.hotelArr=responseBody.data;
        console.log(this.hotelArr);
        if (this.hotelArr.length==0){
          this.commentState=true;
        }else {
          this.commentState=false;
        }
      });
    },
    loadByThemeName(name){
      let url = 'http://localhost:9580/hotels/user/getHotelListBySomethingOfLocation?location='+name;

      /* let formData=this.qs.stringify(this.activeName1.name);*/
      this.axios
          .create({'headers': {'Authorization': localStorage.getItem('jwt')}})
          .get(url).then((response) => {
        let responseBody = response.data;
        this.hotelArr=responseBody.data;
        console.log(this.hotelArr);
        if (this.hotelArr.length==0){
          this.commentState=true;
        }else {
          this.commentState=false;
        }
      });
    }
  },
  mounted() {
    if (localStorage.getItem('location')!=null){
      this.loadByThemeName(localStorage.getItem('location'));
    }
    if (localStorage.getItem('searchContent')!=null){
      this.loadByContent(localStorage.getItem('searchContent'));
    }
  }
}
</script>

<style>
.show-size {
  width: 950px;
}
.head {
  color: #333;
  text-align: center;
  line-height: 60px;
  box-sizing: border-box;
}

.head1 {
  margin-top: 100px;
  padding-left: 0px;
  width: 950px;
}

.el-main {
  color: #333;
  height: 100%;
  padding-left: 450px;
  box-sizing: border-box;
}

.el-menu-demo {
  width: 100%;
  margin: 0 auto;
  padding-left: 350px;
  box-sizing: border-box;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04)
}

.head-r-l a {
  text-decoration: none;
}

.el-row {
  margin-bottom: 20px;
}

:last-child {
  margin-bottom: 0;
}

.el-col {
  border-radius: 4px;
}

.bg-purple-dark {
  background: #99a9bf;
}

.bg-purple {

}

.bg-purple-light {
  background: #e5e9f2;
}

.grid-content {
  border-radius: 4px;
  min-height: 36px;
}

.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}

h2 {
  margin: 0;
  font-size: 20px;
}

.span-s {
  font-size: 15px;
}

.hotel-live {
  text-align: center;
  width: 950px;
  margin-top: 50px;
}

.el-tabs-s {
  width: 950px;
  box-sizing: border-box;
}

.monitorTop {
  /*!/ position: relative;  相对定位,*/
  position: relative;
  /*vw是width of view(port)的缩写；
100vw表示百分之百的视图宽度；
123px是需要减去的宽度；
减号的两边必须都有至少一个空格*/
  height: calc(50% - 123px);
}

.monitorTop .el-tabs__item {
  font-size: 20px !important;
}

::v-deep .el-tabs__nav-scroll {
  width: 50%;
  margin: 0 auto
}
.img-s{
  width: 303px;
  height: 220px;
  margin-bottom: 15px;
}
.foot-s{
  background-color: #3e3e3e;
  height: 300px;
  text-align: center;
  color: #bbbbbb;
}
.b1{
  height: 60px;
  font-size: 15px;
}
.span-text{
  z-index: 3;
  position: relative;
  color: white;
  font-size: 25px;
  top: -125px;
  left: 110px;
}
.span-hotel{
  z-index: 3;
  position: relative;
  color: white;
  font-size: 15px;
  top: -35px;
  left: 10px;
}
</style>